package com.lottery.im.module.result.presenter;

import android.app.Activity;
import com.lottery.im.api.ApiClient;
import com.lottery.im.api.observer.ShowTipListObserver;
import com.lottery.im.base.BaseFragmentPresenter;
import com.lottery.im.module.result.view.LongDragonView;
import com.trello.rxlifecycle2.LifecycleProvider;
import com.trello.rxlifecycle2.android.FragmentEvent;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class LongDragonPresenter extends BaseFragmentPresenter<LongDragonView> {

  public LongDragonPresenter(Activity activity, LongDragonView iView,
      LifecycleProvider<FragmentEvent> provider) {
    super(activity, iView, provider);
  }

  /*
   * 查询所有彩种长龙统计-预测
   * */
  public void queryAllStatistics() {
    ApiClient.getApiRetrofitInstance()
        .queryAllStatistics()
        .throttleFirst(2, TimeUnit.SECONDS)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .compose(provider.bindToLifecycle())
        .subscribe(new ShowTipListObserver<List<String>>(activity) {
          @Override public void onSuccess(List<List<String>> list) {
            iView.querySuccess(list);
          }
        });
  }
}
